import { createElement, HTMLAttributes, type FC } from 'react';
import classNames from 'classnames';

import { itemMetaDefaultProps } from './defaultProps';
import type { ItemMetaOptions } from './type';

export interface ItemMetaProps extends ItemMetaOptions, HTMLAttributes<HTMLDivElement> {}

const ItemMeta: FC<ItemMetaProps> = (props) => {
  const { className, children, forwardedRef, ...itemMetaProps } = props;

  return createElement(
    'div',
    { ref: forwardedRef, className: classNames('meta', className), ...itemMetaProps },
    children,
  );
};

ItemMeta.displayName = 'ItemMeta';
ItemMeta.defaultProps = itemMetaDefaultProps;

export default ItemMeta;
